<template>
    <el-collapse-transition>
        <layout-card v-if="tableData.length">
            <template slot="head">
                {{title}}
            </template>

            <div>
                <push-list-item
                    v-for="(item, index) in tableData"
                    :key="index"
                    :data="item"
                ></push-list-item>
            </div>
        </layout-card>
    </el-collapse-transition>
</template>

<script>
import layoutCard from '@components/sys/layout-card';

import pushListItem from '../components/push-list-item';

export default {
    components: {
        layoutCard,
        pushListItem,
    },
    props: {
        title: {
            type: String,
            default: '相关文档',
        },
    },
    data() {
        return {
            tableData: []
        }
    },
    methods: {
        queryData() {
            this.$get(`${this.$store.state.api.tbUrl}/document/similarlist.json`, {
                limit: 6,
                documentguid: this.$route.params.guid,
            }, data => {
                this.tableData = data || [];

                this.$nextTick(() => {
                    if (this.tableData.length > 0) {
                        this.$emit('update');
                    }
                });
            });
        },
    },
    mounted() {
        this.queryData();
    },
};
</script>

<style lang="scss" scoped>
    
</style>